<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/common/common.css" />
		<link rel="stylesheet" href="../../css/bookdetails/comment.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" id="evau"></a>
			<h1 class="mui-title">评分</h1>
		</header>
		<div class="mui-content">
			<div class="score">
				<div></div>
				<div></div>
				<div></div>
				<div></div>
				<div></div>
				<span>0分</span>
			</div>
			<div>
				<div class="textarea">
					<textarea name="" id="commentContent" cols="30" rows="10" maxlength="500"></textarea>
					<div class="words">
						<div>500</div>/500
					</div>
				</div>
			</div>
			<button type="button" class="mui-btn  mui-btn-primary submit">提交</button>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/libs/zepto_1.1.3.js"></script>
		<script src="../../js/common/common.js"></script>
		<script type="text/javascript">
			mui.init()

			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
				var id = self.parameter;
				console.log(id)
				var num = $(".words div").text()
				$(".score div").on("tap", function() {
					$(".score div").removeClass("starnumber")
					for(var i = 0; i < $(this).index() + 1; i++) {
						$(".score div").eq(i).addClass("starnumber")
					}
					$(".score span").text($(this).index() + 1 + "分")
					$(".score span").css("color", "#ffbc01")
				})
				$(".textarea textarea").on("keyup", function() {
					$(".words div").text(num - $(".textarea textarea").val().length)
				})
				var oldback = mui.back;

				mui.back = function() {
					oldback();
					//恢复a页面的显示状态；
					mui.currentWebview.opener().show('none');
					//继续执行b页面原有的返回逻辑
				}
				var tru = true
				$(".submit").on("tap", function() {
					if(!tru) {
						return
					}
					if($(".starnumber").length == 0) {
						mui.toast("不能低于一星")
						return
					}
					if($("#commentContent").val() == "") {
						mui.toast("内容不能为空!")
						return
					}
					tru = false
					common.ajax("student/book/commentBook", {
						uid: common.uid,
						token: common.token,
						bookUid: id,
						mark: $(".starnumber").length,
						commentContent: $("#commentContent").val()
					}, function(data) {
						if(data.code == 200) {
							var list = plus.webview.currentWebview("../bookdetails/details.html").opener();
							mui.fire(list, 'refresh');
							mui.back()
							/*common.open("details.html","details.html",id)
							
							var indexI = plus.webview.getWebviewById("details.html");
	                         mui.fire(indexI,"gohome");*/
							//							var indexI2 = plus.webview.getWebviewById("evaluatae.html");
							//	                         mui.fire(indexI,"gohome");

						} else {
							mui.toast(data.message)
						}
						tru = true
					}, "get")
				})
			})
		</script>
	</body>

</html>